using Headspring.Training.Core.Model;

namespace Headspring.Training.Core.Services.Impl
{
	public class WorkOrderBuilder : IWorkOrderBuilder
	{
		private readonly ICalendar _calendar;
		private readonly IWorkOrderNumberGenerator _numberGenerator;

		public WorkOrderBuilder(IWorkOrderNumberGenerator numberGenerator,
		                        ICalendar calendar)
		{
			_numberGenerator = numberGenerator;
			_calendar = calendar;
		}

		public WorkOrder CreateNewWorkOrder(Employee creator)
		{
			var workOrder = new WorkOrder();
			workOrder.Number = _numberGenerator.GenerateNumber();
			workOrder.CreatedDate = _calendar.GetCurrentTime();
			workOrder.Creator = creator;
			workOrder.Status = WorkOrderStatus.Draft;
			return workOrder;
		}
	}
}